package com.yd.app.mapper;

import com.yd.app.mapper.provider.ShareProvider;
import com.yd.domain.business.Share;
import com.yd.domain.searchParam.ShareParam;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author zy
 * @create 2018-03-12 9:06
 * @desc 分享的mapper
 **/
@Repository
public interface ShareMapper {
    /**
     * @Author: zy
     * @Desc: 录入信息
     * @Date:  2018/3/12
     * @Param
     */
    @Insert("INSERT INTO business_share (id,status,title,des,publishTime,publishUser,goodId)" +
            " VALUES(#{n.id},#{n.status},#{n.title},#{n.des},#{n.publishTime},#{n.publishUser},#{n.goodId})")
    void addShare(@Param("n")Share n);
    /**
     * @Author: zy
     * @Desc: 修改数据
     * @Date:  2018/3/12
     * @Param
     */
    @Update("update business_share set `status`=#{n.status},title=#{n.title},des=#{n.des},goodId=#{n.goodId} where id=#{n.id}")
    void updateShare(@Param("n")Share n);
    /**
     * @Author: zy
     * @Desc: 根据id删除
     * @Date:  2018/3/12
     * @Param
     */
    @Delete("delete from business_share where id=#{id}")
    void deleteShare(@Param("id") String id);
    /**
     * @Author: zy
     * @Desc: 根据id查询
     * @Date:  2018/3/12
     * @Param
     */
    @Select("SELECT n.id,n.`status`,n.title,n.des,n.publishTime,n.publishUser,n.goodId from business_share n  WHERE n.id=#{id}")
    Share findById(@Param("id") String id);
    /**
     * @Author: zy
     * @Desc: 审核状态
     * @Date:  2018/3/12
     * @Param
     */
    @Update("update business_share set `status`=#{n.status} where id=#{n.id}")
    void verifyShare(@Param("n")Share n);
    /**
     * @Author: zy
     * @Desc: 分页查询
     * @Date:  2018/3/12
     * @Param
     */
    @SelectProvider(method = "searchShareList",type= ShareProvider.class)
    List<Share> searchShareList(@Param("shareParam") ShareParam shareParam, @Param("startRow") int startRow, @Param("pageSize") int pageSize);
   /**
    * @Author: zy
    * @Desc: 查询数据总数量
    * @Date:  2018/3/12
    * @Param
    */
    @SelectProvider(method = "searchShareCount",type= ShareProvider.class)
    int searchShareCount(@Param("shareParam") ShareParam shareParam);
}
